package com.copm.demonstrationsystem.controller.introductionfeatures;

import com.copm.demonstrationsystem.commons.response.ResponseStatus;
import com.copm.demonstrationsystem.commons.util.ControllerUtils;
import com.copm.demonstrationsystem.dao.commons.ImageDao;
import com.copm.demonstrationsystem.service.introductionfeatures.FacilityService;
import com.copm.demonstrationsystem.service.introductionfeatures.LandscapeService;
import com.copm.demonstrationsystem.service.introductionfeatures.commons.SinglonImageHandle;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: Yuan Baiyu
 * @Date: Created in 15:26 2018/4/23
 */

@RestController
@RequestMapping("/facility")
@CrossOrigin
public class FacilityController {

    @Autowired
    FacilityService facilityService;

    //获取页面信息（全部图片）
    @GetMapping
    @ApiOperation("周边设施页面的信息获取接口")
    public ResponseStatus getPage() {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                facilityService.getFacilityImage());
    }

    //修改图片
    @ApiOperation("修改图片")
    @ApiImplicitParam(name = "file",value = "新图片信息"
            ,dataType = "file",paramType = "form",required = true)
    @PostMapping()
    public ResponseStatus modifyImage(@RequestPart("file") MultipartFile file) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                facilityService.modifyFacilityImage(file));
    }

    //修改“周边设施”页面toUrl信息
    @PostMapping("/tourl")
    @ApiOperation("修改toUrl")
    @ApiImplicitParam(name = "tourl", value = "新的toUrl"
            , dataType = "String", paramType = "query", required = true)
    public ResponseStatus modifyText(@RequestParam("tourl") String tourl) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                facilityService.modifyFacilityToUrl(tourl));
    }


//    //删除图片
//    @DeleteMapping("/{id}")
//    @ApiOperation("删除图片")
//    @ApiImplicitParam(name = "id", value = "待删除的图片标识ID"
//            , dataType = "Long", paramType = "path", required = true)
//    public ResponseStatus deleteImage(@PathVariable("id") Long id) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                facilityService.deleteFacilityImage(id));
//    }
//
//    //上传图片
//    @PostMapping
//    @ApiOperation("待上传的图片")
//    @ApiImplicitParam(name = "file", value = "新的背景图片"
//            , dataType = "file", paramType = "form", required = true)
//    public ResponseStatus addImage(@RequestPart("file") MultipartFile file) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                facilityService.addFacilityImage(file));
//    }

}
